/*
 	Software Author: Mike Moore
 	Vectrics Flashrecruit
 	Open source job board and applicant tracking system.  Built with enterprise Java.
 */
package org.vectrics.skill.struts.pagelist;

import org.apache.log4j.Logger;
import org.vectrics.common.html.Form;
import org.vectrics.common.pagelist.PageList;
import org.vectrics.recruiter.RecruitServiceLocator;
import org.vectrics.skill.Skill;
import org.vectrics.skill.SkillRating;
import org.vectrics.skill.SkillSearchCriteria;
import org.vectrics.skill.UserEvaluation;
import org.vectrics.skill.struts.SkillPageList;

public class PersonSkillPageListTag extends SkillPageListTag {
	private static final long serialVersionUID = 324324231678383952L;

	private Logger log = Logger.getLogger(this.getClass());
	private UserEvaluation userEvaluation = null;

	
	
	@Override
	protected Form createForm() {
		return(new Form());
	}

	@Override
	protected String getFormAction() {
		return this.getContextPath() + "/admin/user/skill/skillListEntryFinished.do";
	}

	@Override
	protected boolean getMakeCheckBoxes() {
		return false;
	}

	@Override
	protected boolean getAllowRatingEntry() {
		return true;
	}

	@Override
	protected String getPageListLink() {
		return this.getContextPath() + "/admin/user/skill/skillListEntry.do";
	}
	
	
	@Override
	protected String getFinishLink() {
		return this.getContextPath() + "/admin/user/skill/saveSkillListEntry.do";
	}
	
	
	/**
	 * 
	 * @return
	 */
	protected UserEvaluation getUserEvaluation() {
		if (this.userEvaluation == null) {
			Long userEvaluationId = new Long(this.getRequest().getParameter("evaluationId"));
			this.userEvaluation = RecruitServiceLocator.getSkillProvider().findEvaluationById(userEvaluationId);
		}
		return(this.userEvaluation);
	}
	
	
	@Override
	protected SkillRating getSkillRating(Skill skill) {
		UserEvaluation evaluation = this.getUserEvaluation();
		log.info("evaluation.id = " + evaluation.getId());
		return RecruitServiceLocator.getSkillProvider().findUserSkillRating(evaluation, skill);
	}

	@Override
	protected PageList createPageList() {
		SkillSearchCriteria criteria = new SkillSearchCriteria();
		criteria.setNonRateableSkills(false);
		criteria.setRateableSkills(true);
		PageList pageList = new SkillPageList(criteria);
		pageList.setPageSize(25);
		return pageList;
	}

}
